package com.ruoyi.jjkc.yfxmsx.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.jjkc.qyjbxx.domain.Qyjbxx;
import com.ruoyi.jjkc.yfxmsx.domain.Yfxmsx;
import com.ruoyi.jjkc.yfxmsx.mapper.YfxmsxMapper;
import com.ruoyi.jjkc.yfxmsx.service.IYfxmsxService;
import org.apache.ibatis.annotations.Update;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 研发项目筛选Controller
 *
 * @author huacai
 * @date 2024-12-05
 */
@RestController
@RequestMapping("/jjkc/yfxmsx")
public class YfxmsxController extends BaseController {
    @Resource
    private IYfxmsxService yfxmsxService;

    @Resource
    private YfxmsxMapper yfxmsxMapper;

    /**
     * 查询研发项目筛选列表
     */
    @GetMapping("/selectYfxmsxList")
    public TableDataInfo selectYfxmsxList(Yfxmsx yfxmsx) {
        startPage();
        List<Yfxmsx> list = yfxmsxService.selectYfxmsxList(yfxmsx);
        return getDataTable(list);
    }

    /**
     * 是否可加计扣除
     */
    @PutMapping("/updateKJjkc")
    @PreAuthorize("@ss.hasPermi('jjkc:yfxmsx:updateKJjkc')")
    public AjaxResult updateKJjkc(@RequestParam Integer xmsbId, @RequestParam String sfKJjkc, @RequestParam String nd) {
        return toAjax(yfxmsxMapper.updateKJjkc(xmsbId, sfKJjkc, nd));
    }

    /**
     * 导出研发项目筛选列表Excel
     */
    @PreAuthorize("@ss.hasPermi('jjkc:yfxmsx:export')")
    @Log(title = "研发项目筛选", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Yfxmsx yfxmsx) {
        System.out.println(response);
        List<Yfxmsx> list = yfxmsxService.selectYfxmsxList(yfxmsx);
        ExcelUtil<Yfxmsx> util = new ExcelUtil<Yfxmsx>(Yfxmsx.class);
        util.exportExcel(response, list, "研发项目筛选数据", "研发项目筛选_" + yfxmsx.getNd() + "年加计扣除活动");
    }


}
